package cn.caidabao.camunda_demo.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;

/**
 * @author cjn
 * @since 2024-07-16 11:54
 */
@Component
public class MybatisPlusFieldMetaObjectHandler implements MetaObjectHandler {
    private final String createTime = "createTime";
    private final String updateTime = "updateTime";

    @Override
    public void insertFill(MetaObject metaObject) {
        strictInsertFill(metaObject, createTime, LocalDateTime.class, LocalDateTime.now());
        strictInsertFill(metaObject, updateTime, LocalDateTime.class, LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject){
        strictInsertFill(metaObject, updateTime, LocalDateTime.class, LocalDateTime.now());
    }
}
